package com.xhwl.centiotdata.controller;

import com.xhwl.centiotdata.service.sysconfig.ISsyConfigService;
import com.xhwl.centiotdata.suppliersystem.huawei.sheshiyun.IAuthApi;
import com.xhwl.common.pojo.ResultJson;
import com.xhwl.common.pojo.config.SsyConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: luyi
 * @Description: 华为设施云授权
 * @Date: Create in 14:46 2021/12/16
 */
@RestController
public class SheshiyunContorller {

    @Autowired
    private IAuthApi authApi;

    @Autowired
    private ISsyConfigService ssyConfigService;

    @RequestMapping(value = "/sheshiyun/auth")
    public ResultJson auth(Integer projectId, HttpServletResponse response){
        if(null == projectId){
            return ResultJson.fail("参数错误");
        }
        return authApi.login(projectId);
    }

    @RequestMapping(value = "/sheshiyun/config")
    public ResultJson config(Integer projectId){
        if(null == projectId) {
            return ResultJson.fail("参数错误");
        }
        SsyConfig config = ssyConfigService.findByProjectId(projectId);
        return ResultJson.success(config);
    }
}
